package practices;

import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;

public class customer{
    public static void main(String arg[]){
        List<goods> list=new CopyOnWriteArrayList<goods>(){
            {
                add(new goods());
                add(new goods("1","milk",3,24));
                add(new goods("14","coffee",7,0));
                add(new goods("5","tea",5,3));
                add(new goods("10","juice",3.5,6));
                add(new goods("7","coke",3,6));
            }
        };
//        list.parallelStream().filter(g->g.getPrice()<5).forEach(g->System.out.println(g.getName()));
        Comparator<goods> com=(goods g1,goods g2)->g1.getNo().compareTo(g2.getNo());
        list.parallelStream().
                sorted((g1,g2)-> (int) (g1.getPrice()-g2.getPrice()))
                .collect(Collectors.toList()).
                forEach(g->System.out.println(g.getName()+" "+g.getPrice()));

    }
    public void judge1(){

    }
}
class goods{
    private int number;
    private double price;
    private String name;
    private String no;
    public goods(){
        this.number = 12;
        this.price = 2;
        this.name = "water";
        this.no = "0";
    }
    public goods( String no,String name, double price,int number) {
        this.number = number;
        this.price = price;
        this.name = name;
        this.no = no;
    }
    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }
}